# Convert stata ym to R date (first day of month)
# stata ym of 0 is Jan 1960

stata_ym_to_R_date <- function(ymval){
  yr_diff <- floor(ymval/12)
  mon_diff <- ymval - yr_diff * 12
  yr <- 1960 + yr_diff
  mon <- mon_diff + 1

  return(as.Date(paste0(yr, "-", mon, "-01"), "%Y-%m-%d"))
}

